function removeSpace(str) {
  return str.trim();
}

function formValidate(str, flag) {
  if (flag === "require") {
    return str ? true : false;
  } else if (flag === "email") {
    return /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/.test(str);
  } else if (flag === "phone") {
    return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(str);
  }
}

export { removeSpace, formValidate };
